package com.zhw.service.impl;

import com.zhw.mapper.ContactMapper;
import com.zhw.pojo.entry.CustomerContact;
import com.zhw.pojo.vo.ContactVO;
import com.zhw.service.ContactService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class ContactServiceImpl implements ContactService {

    @Autowired
    ContactMapper contactMapper;

    @Override
    public List<ContactVO> list(Integer cusId) {
        return contactMapper.list(cusId);
    }


    @Override
    public void add(CustomerContact customerContact) {
        customerContact.setCreateDate(LocalDateTime.now());
        customerContact.setUpdateDate(LocalDateTime.now());
        customerContact.setIsValid(0);
        contactMapper.save(customerContact);

    }


    @Override
    public CustomerContact getContactByID(Integer id) {
        return contactMapper.getByID(id);
    }

    @Override
    public void update(CustomerContact customerContact) {
        customerContact.setUpdateDate(LocalDateTime.now());
        contactMapper.update(customerContact);

    }


    @Override
    public void deleteContactById(Integer id) {
        contactMapper.deleteByID(id);
    }
}
